Skip to content

Conversation

@bruceg
Copy link
Member

@bruceg bruceg commented Jan 6, 2026

Summary

The source and transform buffer utilization metrics currently measure either the
instantaneous level or a histogram, neither of which is a reliable single-valued
reflection of the actual status. For this purpose, we introduce a mean metric
that uses the EWMA calculations to produce a simple moving average that will
better track the actual value.

Vector configuration

[sources.metrics]
type = "internal_metrics"

[transforms.filter]
type = "filter"
inputs = ["metrics"]
condition.type = "is_metric"

[sinks.console]
type = "console"
inputs = ["filter"]
encoding.codec = "text"

How did you test this PR?

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

bruceg added 4 commits January 6, 2026 16:36
The source and transform buffer utilization metrics currently measure either the
instantaneous level or a histogram, neither of which is a reliable single-valued
reflection of the actual status. For this purpose, we introduce a `mean` metric
that uses the EWMA calculations to produce a simple moving average that will
better track the actual value.
@bruceg bruceg requested review from a team as code owners January 6, 2026 23:11
@bruceg bruceg added type: enhancement A value-adding code change that enhances its existing functionality. domain: observability Anything related to monitoring/observing Vector domain: sources Anything related to the Vector's sources domain: transforms Anything related to Vector's transform components labels Jan 6, 2026
@github-actions github-actions bot added domain: sinks Anything related to the Vector's sinks domain: external docs Anything related to Vector's external, public documentation domain: core Anything related to core crates i.e. vector-core, core-common, etc and removed domain: transforms Anything related to Vector's transform components labels Jan 6, 2026
@datadog-vectordotdev
Copy link

datadog-vectordotdev bot commented Jan 6, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 75e8243 | Docs | Was this helpful? Give us feedback!

Copy link
Contributor

@maycmlee maycmlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of small suggestions

@bruceg bruceg requested a review from maycmlee January 7, 2026 17:05
Copy link
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +165 to +176
let mut result = f64::NAN;
self.average
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |current| {
let average = if current.is_nan() {
point
} else {
point.mul_add(self.alpha, current * (1.0 - self.alpha))
};
result = average;
average
});
result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut result = f64::NAN;
self.average
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |current| {
let average = if current.is_nan() {
point
} else {
point.mul_add(self.alpha, current * (1.0 - self.alpha))
};
result = average;
average
});
result
self.average
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |current| {
if current.is_nan() {
point
} else {
point.mul_add(self.alpha, current * (1.0 - self.alpha))
}
})

I think this would work the same as fetch_update returns an f64

Copy link
Member Author

@bruceg bruceg Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that fetch_update returns the old value (hence the mnemonics of fetch-then-update), but we want to return the updated average which is only accessible in the closure or by adding another fetch which adds to the expense.

@bruceg bruceg enabled auto-merge January 8, 2026 18:25
@bruceg bruceg added this pull request to the merge queue Jan 8, 2026
Merged via the queue into master with commit 4daa1f8 Jan 8, 2026
102 checks passed
@bruceg bruceg deleted the utilization-ewma branch January 8, 2026 18:58
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

domain: core Anything related to core crates i.e. vector-core, core-common, etc domain: external docs Anything related to Vector's external, public documentation domain: observability Anything related to monitoring/observing Vector domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources type: enhancement A value-adding code change that enhances its existing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants